import { userStore } from '@/biz/user'
import server from '@/config/server/index.js'
import dt from '@dt/dt'

let api = {
  list: server.api().post('/api/customer/pageList'),
  detail: server.api().get('/api/customer/selectDetail')
}

function list() {
  return api.list.fetch({ createId: userStore().info.id, rows: 130 })
}

function detail(id) {
  return api.detail.fetch({ id }).then((res) => {
    res.customerType = dt.dictInfo().__value('CustomerType', res.customerType)
    res.wishPrice = dt.dictInfo().__value('wishPrice', res.wishPrice)
    res.propertyType = dt.dictInfo().__value('propertyType', res.propertyType)
    res.receiveStatus = dt.dictInfo().__value('receiveStatus', res.status)
    return res
  })
}

export default {
  list,
  detail
}
